<div id="workflow_ildds" class="easyui-layout tab_a" fit="true">
    <div data-options="region:'center',border:false">
        <table id="workflow_list"></table>
        <div id="workflowboxtoolbar" style="padding:5px;height:auto">
            <div>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="dialog_public('新建工作','workflow/flow_new','550','200')">新建</a>
                <label style=" float:right;" >
                    <input id="workflow_search_key" class="workflow_search_form textbox" style="width:200px;" type="text">
                    <a href="#" class="easyui-linkbutton workflow_search_form" plain="true"  iconCls="icon-search" onclick="advanced_search('workflow','workflow_search_key')">搜索</a>
                    <a id="workflow_advancedSearch" href="javascript:void(0)" class="easyui-linkbutton" plain="true" onclick="advanced_search('workflow','高级')">高级</a>
                </label>
            </div>
        </div>
	</div>
</div>


<script>
//待办工作数据构造方法，包括列表属性设置，字段设置，双击设置

$('#workflow_list').datagrid({
	url:'<?php echo base_url('workflow/workflow_data');?>',
	singleSelect:true,
	pagination:true,
	pageSize:50,
	pageList:[30,50,100],
	fit:true,
	fitColumns:true,
	border:false,
	queryParams:{},
	sortName:'flow_run_ps.ps_flag',
	sortOrder:'asc',
	toolbar:'#workflowboxtoolbar',
	columns:[[
		{field:'id',title:'流水号',width:20,align:'center'},
		{field:'title',title:'工作名称',width:200},
		{field:'begin_user',title:'发起人',width:20,align:'center'},
		{field:'ps_id',title:'流程',width:20,align:'center',
			formatter: function(value,row,index){
				//return "<div><a href='#' class='editcls' onclick=\"javascript:workflow_flowchart('"+row.id+"')\">第"+row.ps_num+"步</a></div>";
				return "<div><a href='#' class='editcls' onclick=\"javascript:dialog_public('流程步骤','workflow/flow_chart/"+row.id+"','550','400')\">第"+row.ps_num+"步</a></div>";
			}
		},
		{field:'begin_datetime',title:'发起日期',width:40,align:'center',sortable:'true'},
		{field:'isattach',title:'操作',width:70,
			formatter: function(value,row,index){
				var str = '';
				str = "<div>";
				if(row.ps_flag == 1 || row.ps_flag == 2){
					str += "<a href='#' class='editcls' data-options=\"iconCls:'icon-page-white-edit'\" onclick=\"javascript:flow_transact('"+row.id+"','"+row.ps_id+"','"+row.title+"')\">办理</a>";	
					if(row.ps_flag == 2){
						str += "<a href='#' class='editcls' data-options=\"iconCls:'icon-arrow-down'\" onclick=\"javascript:dialog_public('选择下一步办理人','workflow/flow_next/"+row.id+"/"+row.ps_id+"/"+encodeURIComponent(row.title)+"','700','500')\">转交</a><a href='#' class='editcls' data-options=\"iconCls:'icon-accept'\" onclick=\"javascript:flow_end('"+row.id+"','"+row.ps_id+"')\">结束</a>";	
						if(row.begin_user == '<?php echo $this->session->userdata('user_name')?>'){
							str += "<a href='#' class='editcls' data-options=\"iconCls:'icon-arrow-cross'\" onclick=\"javascript:flow_del('"+row.id+"')\">删除</a>";
						}
					}
				}else if(row.ps_flag == 3){
					str += "<a href='#' class='editcls' data-options=\"iconCls:'icon-arrow-undo'\" onclick=\"javascript:flow_back('"+row.id+"','"+row.ps_id+"')\">收回</a>";
				}
				str += "</div>";
				return str;
			}
		}
	]],
	onDblClickRow:function(index,data){
		//workflow_handle_checkout(data.id,data.ps_id,data.title);
		dialog_public('查看工作','workflow/flow_checkout/'+data.id+"/"+data.ps_id);
	},  
	onLoadSuccess:function(data){ 
		var pager = $(this).datagrid('getPager');
			pager.pagination({
				displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
			});
		$('.editcls').linkbutton({plain:true});  
	},
	groupField:'ps_flag',
	view: groupview,
	groupFormatter:function(value, rows){
		
		if(value == 1){
			value = '未接收';
		}else if(value == 2){
			value = '办理中';	
		}else if(value == 3){
			value = '已转交';	
		}else if(value == 4){
			value = '已办结';
		}
		
		return value + ' - ' + rows.length + ' 条';
	}
});	

</script>